package com.noahplat.person.controller;

import com.noahplat.common.utils.Result;
import com.noahplat.person.pojo.Ehrs;
import com.noahplat.person.service.EhrsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @ClassName: EhrsController
 * @Description: 医疗记录对外接口
 * @Author 李景星
 * @Date 2021/3/6
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/ehrs")
@Validated
public class EhrsController {

    @Autowired
    private EhrsService ehrsService;

    /**
     * 获取医疗记录
     * @param pid
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:EhrsController:getEhrs')")
    @GetMapping("/getEhrs")
    public Result getEhrs(@NotNull(message = "人员ID不能为空 ") @Min(value = 1, message = "人员ID不合法") Long pid){
        return ehrsService.getEhrs(pid);
    }

    /**
     * 更新医疗记录
     * @param ehrs
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:EhrsController:updateEhrs')")
    @PutMapping("/updateEhrs")
    public Result updateEhrs(@RequestBody Ehrs ehrs){
        return ehrsService.updateEhrs(ehrs);
    }


}
